using UnityEngine;
using System.Collections;

/// <summary>
/// Interface for path, which could be lines, curves, circles, and
/// everything that could be descripted using a parametric equation.
/// </summary>
public interface IPath 
{
	/// <summary>
	/// Anchor is used to control tagent and length of a path,
	/// for example, a line has two anchors positioned at two 
	/// end-poins of the line, and a 5-th bezier curve has six
	/// anchors.
	/// </summary>
	void SetAnchor (int index, Vector3 anchor);
	
	/// <summary>
	/// Gets anchor.
	/// </summary>
	Vector3 GetAnchor (int index);
	
	/// <summary>
	/// Sample current path using successive lines, large sampleTimes
	/// could led a more smooth appearence than a small sampleTimes
	/// </summary>
	void Sample (int sampleTimes);
	
	/// <summary>
	/// Gets a point on this path, of which y compnent is always zero.
	/// The returned point will not be exactly on this path for most of
	/// the time, but somewhere between two sampled points of the path, 
	/// S1 and S2, where sampled length of this curve before S1 is samller 
	/// than length and sampled length of this curve before S2 is larger 
	/// than length.
	/// </summary>
	Vector3 GetXZPointOnCurve (float length, out Vector3 tagentXZ);
	
	/// <summary>
	/// Get point on the curve with t, which is used in the underline
	/// parametric equation and should always between 0 and 1.
	/// </summary>
	Vector3 Solve (float t);
	
	/// <summary>
	/// Render this path in editor mode. Call this method in OnDrawGizmos.
	/// </summary>
	void Render ();
	
	/// <summary>
	/// Gets the number of anchors of this path.
	/// </summary>
	int anchorCount { get; }
	
	/// <summary>
	/// Gets the sampled length of this path.
	/// </summary>
	float sampledLength { get; }
	
	/// <summary>
	/// Inversed path shares the same anchor with this one, but inversed
	/// anchor order.
	/// </summary>
	IPath inversedPath { get; set; }
}
